package com.mail.server.controller;


import com.mail.model.db.SmsFlashPromotionProductRelation;
import com.mail.server.common.R;
import com.mail.server.service.SmsFlashPromotionProductRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品限时购与商品关系表 前端控制器
 * </p>
 *
 * @author WJZ
 * @since 2022-06-20
 */
@RestController
@RequestMapping("/flashProductRelation")
public class SmsFlashPromotionProductRelationController {
    @Autowired
    private SmsFlashPromotionProductRelationService smsFlashPromotionProductRelationService;

    @PostMapping(value = "/create")
    public R<String> create(@RequestBody List<SmsFlashPromotionProductRelation> list) {
        return smsFlashPromotionProductRelationService.create(list);
    }

    @PostMapping(value = "/delete/{id}")
    public R delete(@PathVariable Long id) {
return  smsFlashPromotionProductRelationService.delete(id);
    }
    @GetMapping(value = "list")
    public R list(Long flashPromotionId,Long flashPromotionSessionId,@RequestParam(defaultValue = "1") Long pageNum,
                  @RequestParam(defaultValue = "10") Long pageSize ){
return smsFlashPromotionProductRelationService.list(flashPromotionId,flashPromotionSessionId,pageNum,pageSize);
    }
    @PostMapping("update/{id}")
    public R update(@PathVariable Long id,@RequestBody SmsFlashPromotionProductRelation relation){
      return   smsFlashPromotionProductRelationService.update(id,relation);
    }
@GetMapping("{id}")
    public R getProductionMessage(@PathVariable Long id){
        return smsFlashPromotionProductRelationService.getProductionMessage(id);
}

}
